package com.example.springboot.controller;


import com.example.springboot.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

@Controller
public class HelloController {
    @Value("${person.name}")
    private String name;
    @Value("${person.birthday}")
    private String birthday;
    
    @Autowired
    private Person person;
    @GetMapping("/hello")
    @ResponseBody
    public String hello(){
        return  "hello "+person.getName()+"   爱好"+person.getHobby().toString()+"  出生日期" +new SimpleDateFormat("yyyy-MM-dd").format(person.getBirthday());
    }
    
    @GetMapping("/exception")
    @ResponseBody
    public String exception() {
        if (Math.random()<0.5){
            int n=1/0;
        }
        return "正常";
    }
}
